import Vue from 'vue'

const AlarmConstructor = Vue.extend(require('./Alarm.vue').default)

const Alarm = () => {
  const AlarmInstance = new AlarmConstructor()
  AlarmInstance.vm = AlarmInstance.$mount() // 挂载但是并未插入dom，是一个完整的Vue实例
  AlarmInstance.vm.visible = true
  AlarmInstance.dom = AlarmInstance.vm.$el
  document.body.appendChild(AlarmInstance.dom) // 将dom插入body
  return AlarmInstance.vm
}

export default {
  install: Vue => {
    Vue.prototype.$alarm = Alarm // 将Notice组件暴露出去，并挂载在Vue的prototype上
  }
}
